package com.weipt.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author weipt
 * @description rabbitmq配置类-direct模式
 * @date 2024/1/9 22:23
 */
@Configuration
public class DirectRabbitMqConfig {

    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("direct-exchange-springboot", true, false);
    }

    @Bean
    public Queue smsDirectQueue(){
        return new Queue("sms-direct-queue", true);
    }

    @Bean
    public Queue emailDirectQueue(){
        return new Queue("email-direct-queue", true);
    }

    @Bean
    public Queue msgDirectQueue(){
        return new Queue("msg-direct-queue", true);
    }

    @Bean
    public Binding smsDirectBinding(){
        return BindingBuilder.bind(smsDirectQueue()).to(directExchange()).with("sms");
    }

    @Bean
    public Binding emailDirectBinding(){
        return BindingBuilder.bind(emailDirectQueue()).to(directExchange()).with("email");
    }

    @Bean
    public Binding msgDirectBinding(){
        return BindingBuilder.bind(msgDirectQueue()).to(directExchange()).with("msg");
    }


}
